<?php
namespace app\index\validate;

use think\Validate;

class Address extends Validate
{

    protected $rule = [
        'name' => 'require',
        'tel' => 'require|checkTel',
        'sca_name' => 'require',
        'address' => 'require',
        'is_default' => 'in:0,1',
    ];

    protected $message = [
        'name.require' => '请填写收货人姓名',
        'tel.require' => '请选择收货人手机号码',
        'sca_name.require' => '请选择收货省市区信息',
        'address.require' => '请填写详细地址',
        'is_default.in' => '参数错误：is_default'
    ];

    /**
     * 验证手机格式
     * @param $value
     * @return bool|string
     */
    protected function checkTel($value)
    {
        if (checkTel($value)) {
            return true;
        } else {
            return '手机号格式错误';
        }
    }
}


